import fs from "fs";
import path from "path";
export default function (dirname) {
  return function (req, res, next) {
    let filepath = path.join(dirname, req.path);
    fs.access(filepath, function (err) {
      if (err) {
        next(); // 中间件
      } else {
        res.sendFile(filepath);
      }
    });
  };
}
